import { createBrowserRouter } from "react-router-dom";
import Login from "@/pages/Login";
import AuthRoute from "@/components/AuthRoute";
import Layout from "@/pages/Layout";
import { lazy, Suspense } from "react";

const Home=lazy(()=>import('@/pages/Home'))
const Artcle=lazy(()=>import('@/pages/Artcle'))
const Publish=lazy(()=>import('@/pages/Publish'))
const router = createBrowserRouter([
  {
    path: '/',
    element: <AuthRoute><Layout/></AuthRoute>,
    children:[
      {
        index:true,
        element:<Suspense fallback={'loading'}><Home/></Suspense> 
       },
      {
        path:'article',
        element:<Suspense fallback={'loading'}> <Artcle/> </Suspense>
      },
   
      {
        path:'publish',
        element:<Suspense fallback={'loading'}><Publish/></Suspense>    

      }
    ]
  },
  {
    path: '/login',
    element: <Login />,
  },
])
export default router